package logic;

/**
 * 配置信息(单例模式)
 * @author 骆焕
 *
 */
public class ConfigInfo {
	
	// 懒汉式对象
	private static ConfigInfo configInfo = null;
	private ConfigInfo() {
		
	}
	
	/**
	 * 应答超时
	 */
	public static final String KEY_RESPONSE_TIMEOUT = "responseTimeout";
	public int responseTimeOut;
	/**
	 * 监控间隔时间
	 */
	public static final String KEY_MONITOR_INTERVAL = "monitorInterval";
	public int monitorInterval;
	/**
	 * 文本框记录行数
	 */
	public static final String KEY_JTEXT_ROWS = "jTextRows";
	public int jTextRows;
	/**
	 * 心跳间隔
	 */
	public static final String KEY_HEART_INTERVAL = "heartInterval"; 
	public int heartInterval;
	/**
	 * 心跳帧
	 */
	public static final String KEY_HEART_FRAME = "heartFrame";
	public String heartFrame;
	/**
	 * 应答帧
	 */
	public static final String KEY_RESPONSE_FRAME = "responseFrame";
	public String responseFrame;
	/**
	 * 大小端
	 */
	public static final String KEY_BYTE_ORDER = "byteOrder"; 
	public int byteOrder;
	/**
	 * 编解码方式
	 */
	public static final String KEY_ENCODER_STYLE = "encoderStyle"; 
	public int encoderStyle;
	/**
	 * 服务IP地址
	 */
	public static final String KEY_SERVER_IP = "serverIP"; 
	public String serverIP;
	/**
	 * 服务端口号
	 */
	public static final String KEY_SERVER_PORT = "serverPort";
	public int serverPort;
	
	/**
	 * 获取单例对象
	 * @return
	 */
	public static ConfigInfo getInstance() {
		if (configInfo == null) {
			configInfo = new ConfigInfo();
			configInfo.responseTimeOut = Integer.valueOf(PropHelper.getPropValue(KEY_RESPONSE_TIMEOUT));
			configInfo.monitorInterval = Integer.valueOf(PropHelper.getPropValue(KEY_MONITOR_INTERVAL));
			configInfo.jTextRows = Integer.valueOf(PropHelper.getPropValue(KEY_JTEXT_ROWS));
			configInfo.heartInterval = Integer.valueOf(PropHelper.getPropValue(KEY_HEART_INTERVAL));
			configInfo.heartFrame = PropHelper.getPropValue(KEY_HEART_FRAME);
			configInfo.responseFrame = PropHelper.getPropValue(KEY_RESPONSE_FRAME);
			configInfo.byteOrder = Integer.valueOf(PropHelper.getPropValue(KEY_BYTE_ORDER));
			configInfo.encoderStyle = Integer.valueOf(PropHelper.getPropValue(KEY_ENCODER_STYLE));
			configInfo.serverIP = PropHelper.getPropValue(KEY_SERVER_IP);
			configInfo.serverPort = Integer.valueOf(PropHelper.getPropValue(KEY_SERVER_PORT));
		}
		return configInfo;
	}
}
